﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Oracle.DataAccess.Client;

public class orcl
{
	public static OracleConnection conn;

	public static int PasswordCheck(string pass, string oldpass = null)
	{
		return 0;
	}

	~orcl()
	{
		try
		{
			conn.Close();
		}
		catch
		{
		}
	}
}

/*

			OracleCommand commb = new OracleCommand();
			commb.Connection = orcl.conn;
			commb.CommandText = "create role abc";

			try
			{
				commb.ExecuteNonQuery();
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "info", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}


			OracleCommand commc = new OracleCommand();
			commc.Connection = conn;
			commc.CommandType = CommandType.StoredProcedure;
			commc.CommandText = "dbo.store_proc_01";
			// add các param tương ứng với tên param của store proc

			OracleCommand comma = new OracleCommand();
			comma.Connection = conn;
			comma.CommandType = CommandType.Text;
			comma.CommandText = "select * from tmp where id = :id";
			OracleParameter param = comma.Parameters.Add("id", OracleDbType.Int32);
			param.Direction = ParameterDirection.Input;
			param.Value = 1;
			

			try
			{
				OracleDataReader reader = comma.ExecuteReader();
				DataTable dt = new DataTable();
				for (int i = 0; i < reader.FieldCount; i++)
				{
					dt.Columns.Add("field " + i);
				}
				while (reader.Read())
				{
					DataRow row = dt.NewRow();
					row[0] = reader[0];
					row[1] = reader[1];
					dt.Rows.Add(row);
					//MessageBox.Show(reader[0].ToString() + "\n" + reader[1].ToString());
				}
				//dataGridView1.DataSource = dt;
				reader.Close();
				reader.Dispose();
				comma.Parameters.Clear();
				comma.Dispose();
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "info", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
*/